import React from 'react';
import {Route, Switch} from 'react-router-dom';
import Login from "../pages/Login/Login";
import Home from "../pages/Home/Home";
import PrivateRoute from "./PrivateRoute";
export default function MainRouter(props){
    console.log("main_props", props);
    return (
        <Switch>
            <Route path="/login" component={Login}/>
            <PrivateRoute path="/" component={Home} />
        </Switch>
    );
}
// export default function MainRouter(props){
//     let {location}= props;
//     let {pathname} = location;
//     let isLogin = true;
//     let config=[
//         {path:'/', component:Home, auth:true},
//         {path:'/login', component:Login},
//         {path:'/404', component:NotFound}
//     ];
//     let targetRouterConfig = config.find((v) => v.path === pathname);
//     if (isLogin) {
//         if (pathname === "/login") {
//             return <Route path="/login" component={Login}/>
//         } else {
//             if (targetRouterConfig && pathname !== '/404') {
//                 return <Route path={pathname} component={targetRouterConfig.component}/>
//             } else if (pathname === '/404') {
//                 return <Route exact path='/404' component={NotFound}/>
//             } else {
//                 return <Redirect to='/404'/> // 如果路由不合法，重定向到 404 页面
//             }
//         }
//     } else {
//         if(targetRouterConfig && !targetRouterConfig.auth){
//             const {component} = targetRouterConfig;
//             return <Route path={pathname} component={component}/>
//         }else{
//             return <Redirect to='/login' />;
//         }
//
//     }
// }
